﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace YAMM
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            //do current jobs
            ExecuteJobs();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
            //Application.Run(new Form1());
        }

        /// <summary>
        /// Execute any saved job
        /// </summary>
        static void ExecuteJobs()
        {
            //TODO PluginManager should handle plugin jobs
            List<Job> newList = new List<Job>();
            foreach (Job job in Jobs.jobs)
            {
                switch (job.id)
                {
                    case JobType.Add:
                        newList.Add(job);
                        break;
                    case JobType.Remove:
                        //remove GUID folder
                        System.IO.Directory.Delete(System.IO.Path.Combine(PluginManager.PluginsFolder, job.guid), true);
                        break;
                    default:
                        newList.Add(job);
                        break;
                 }
            }

            Jobs.jobs = newList;
            Jobs.Save();

        }
    }
}
